<template>
  <el-breadcrumb class="app-breadcrumb" separator="/">
    <span style="
    right: 0px;
    height: 10px;
    border-right: 1px solid #686b71;" > </span>
    <a v-if="type=='00'" @click="handleClickOutside">杭云内部ERP管理平台</a>
    <a v-if="type=='05'" @click="handleClickOutside">合作伙伴分润结算平台</a>
    <a v-if="type=='07'" @click="handleClickOutside"></a>
  </el-breadcrumb>

</template>

<script>
export default {
  data() {
    return {
      levelList: null,
      type:"00",
    }
  },
  watch: {
    $route(route) {
      // if you go to the redirect page, do not update the breadcrumbs
      if (route.path.startsWith('/redirect/')) {
        return
      }
      this.getBreadcrumb()
    }
  },
  created() {
    this.getBreadcrumb();
    this.getype();
  },
  methods: {
    getype()
    {
      // getUser(this.$store.state.user.userId).then(response=>{
      //   this.type = response.data.usertype;
      //   console.log(response);
      // })
      this.type = this.$store.state.user.usertype;
     // console.log(this.$store.state.user.usertype);
    },
    getBreadcrumb() {
      // only show routes with meta.title
      let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
      const first = matched[0]

      if (!this.isDashboard(first)) {
        matched = [{ path: '/index', meta: { title: '概览' }}].concat(matched)
      }

      this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
    },
    isDashboard(route) {
      const name = route && route.name
      if (!name) {
        return false
      }
      return name.trim() === 'Index'
    },
    handleLink(item) {
      const { redirect, path } = item
      if (redirect) {
        this.$router.push(redirect)
        return
      }
      this.$router.push(path)
    },
    handleClickOutside() {
      alert('跳转');
    }
  }
}
</script>

<style lang="scss" scoped>
.app-breadcrumb.el-breadcrumb {
  display: inline-block;
  font-size: 14px;
  line-height: 50px;
  margin-left: 8px;

  .no-redirect {
    color: #0d73fc;
    cursor: text;
  }
}
a{margin-left: 20px;font-size: 12px;color: #0d73fc;};
a:hover {color: #0d73fc
} /* 鼠标移动到链接上 */
</style>
